home *** CD-ROM | disk | FTP | other *** search
/ Headline 1 / Headline 1.adf / HDLfiles / inconvex.stc / inconvex
Text File  |  1992-09-02  |  4KB  |  120 lines

  1. ±12       Inconvex Vector Objects
  2. ±13-------------------------------------
  3. ±12by Aragorn/Avalon
  4.  
  5. ±11After  a while you probably get bored
  6. just working with plain convex vector
  7. routines,    because   of   the   few
  8. opportunities they give you to design
  9. objects.  So what you have to do then
  10. is  to  fix your routine a little bit
  11. so  that it's able to handle inconvex
  12. objects.   And that should open a new
  13. horizon  for  you  and let you create
  14. much more interesting objects.
  15.  
  16. First of all you need a normal hidden
  17. line  vector  routine  to  start  out
  18. with.   And  as you know, in a convex
  19. routine  you  draw the lines directly
  20. in  the  screenbuffer, and that works
  21. fine  since  there is no intreference
  22. with  more  than one surface over the
  23. same  area.   However,  when  you are
  24. working  with  inconvex objects, this
  25. overlapping  will  occur.   What  you
  26. have  to  do  then is to draw all the
  27. lines  for  one surface in a separate
  28. buffer,  then  fill  the  buffer, and
  29. blit  it out on the screen.  Then you
  30. clear  the  buffer,  and  do  it over
  31. again  until  you  have taken care of
  32. all  the surfaces.  Now, that is just
  33. a  really simple way of saying it, so
  34. let's  get  a little deeper into what
  35. needs to be done...
  36.  
  37. In addition to your screenbuffers you
  38. will  need  another buffer big enough
  39. for   one  bitplane  in  screen  size
  40. (usually [256*40]=10240 bytes).  This
  41. is  where  you'll  draw  and fill all
  42. your   surfaces   separately   before
  43. blitting  them  onto the screen where
  44. the  complete  object will be created
  45. and  shown.  Since the surface buffer
  46. (the  one explained above) is only in
  47. one  bitplane,  you'll  have to label
  48. every  surface  in  the  declarations
  49. with  the bitplanes you want it to be
  50. shown in.  Here is an example on such
  51. a declaration:
  52.  
  53. ±12dc.w    %10,0,1,1,2,2,3,3,0,-1
  54.  
  55. ±11Here,  the  first  word  shows  which
  56. bitplanes  the  surface will be shown
  57. in.   Then  comes the coordinates the
  58. surface  is  drawn  between (from,to,
  59. from,to...)  and  the last word marks
  60. end  of surface.  Then, after filling
  61. the  surface  it's  time  to blit it.
  62. Let's  say  you  have  the first word
  63. "%10"  in  d0.   You  simply test the
  64. bits  in d0 to find where to blit the
  65. surface.   And  remember to clear the
  66. area  which the surface covers in the
  67. bitplanes  where  it  is  not blitted
  68. out!  Let's look at an example:
  69.  
  70. ±13btst    #0,d0    ; Draw Bpl1? [No]
  71. beq    .No1    ; If No, Skip It!
  72. (BLIT SURFACE IN 1. BITPLANE)
  73. btst    #1,d0    ; Draw Bpl2?
  74. bne    .No1    ; If No, Clear It!
  75. (CLEAR SURFACE'S AREA IN 2. BITPLANE)
  76. .No1:
  77. btst    #1,d0    ; Draw Bpl2? [Yes]
  78. beq    .No2    ; If No, Skip It!
  79. (BLIT SURFACE IN 2. BITPLANE)
  80. btst    #0,d0    ; Draw Bpl1? [No]
  81. bne    .No2    ; If No, Clear It!
  82. (CLEAR SURFACE'S AREA IN 1. BITPLANE)
  83. .No2:
  84.  
  85. ±11The  answers  in the brackets will go
  86. for  the  "%10" combination.  Now all
  87. you  need  to  do  is  to  clear  the
  88. surface-buffer  and  repeat the cycle
  89. until  all  the  surfaces  have  been
  90. processed.   And  then your object is
  91. complete!
  92.  
  93. "Now  wait  a minute", you might say;
  94. "how   can   I  make  sure  that  the
  95. surfaces are blitted out in the right
  96. order?".   Well,  since  there  is no
  97. routine  that  sorts  the surfaces as
  98. they  rotate  and  gets  them  in the
  99. right   order,  we'll  have  to  pre-
  100. arrange  the  surfaces.  That is done
  101. down   in   the   declarations.   The
  102. easiest  way  of explaining how to do
  103. that  is  just  to  switch around the
  104. orders  the  surfaces are declared in
  105. until  it  works.   But here are some
  106. guidelines that you might find handy:
  107.  
  108. ±13*±11 Declare the surfaces that are over,
  109.   in front of, or outside the others
  110.   at the end.
  111. ±13*±11 Declare the surfaces that are shown
  112.   in all bitplanes last, or first.
  113.  
  114.  
  115. ±12Well, that is all I have to say about
  116. inconvex   vector   objects  in  this
  117. article.    Good   luck   with   your
  118. experiments!
  119.  
  120. ±13                    Aragorn/Avalon...ç